package lovoStudy_9_14;

import java.io.*;

/**
 * Created with Intellij IDEA
 * Description:
 *
 * @ return:
 * @ author:zxl
 */
public class Test04 {
    /**
     * 文件拷贝
     * @param source 原文件路径
     * @param dist 目标文件路径
     */
    public void copy(String source,String dist){
        FileInputStream fis = null;
       int n = 0 ;
       byte [] by = new byte[1024];
        try {
            fis = new FileInputStream(source);
            while ((n = fis.read(by)) != -1){
                FileOutputStream fos = null;
                fos = new FileOutputStream(dist);
                fos.write(by,0,n);


            }


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fis != null){
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }


    }
    public static void main(String[] args) {
        Test04 test04 = new Test04();
        test04.copy("1.txt","5.txt");
    }
}
